package com.ran.java_gobang_new.utils;

import com.ran.java_gobang_new.pojo.dao.UserInfo;
import com.ran.java_gobang_new.pojo.request.UserInfoLoginRequest;
import com.ran.java_gobang_new.pojo.response.UserInfoGameHallReponse;
import com.ran.java_gobang_new.pojo.response.UserInfoLoginResponse;
import org.springframework.beans.BeanUtils;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ran
 * Date: 2025-09-03
 * Time: 0:25
 */
public class BeanTrans {
    // 把 UserInfoLoginRequest 转化为 UserLoginResponse, 发送给起前端
    public static UserInfoLoginResponse trans(UserInfoLoginRequest userInfoLoginRequest) {
        if (userInfoLoginRequest == null) {
            throw new NullPointerException("userInfo 转化 UserLoginResponse 发生的空指针");
        }
        UserInfoLoginResponse userLoginResponse = new UserInfoLoginResponse();
        BeanUtils.copyProperties(userInfoLoginRequest,userLoginResponse);
        return userLoginResponse;
    }

    // 把 UserInfo 转化为 UserInfoGameHallReponse, 获取大厅用户信息, 发送给起前端
    public static UserInfoGameHallReponse trans(UserInfo userInfo) {
        if (userInfo == null) {
            throw new NullPointerException("userInfo 转化 UserInfoGameHallRequest 发生的空指针");
        }
        UserInfoGameHallReponse userInfoGameHallRequest = new UserInfoGameHallReponse();
        BeanUtils.copyProperties(userInfo,userInfoGameHallRequest);
        return userInfoGameHallRequest;
    }
}
